package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;
import com.lxj.xpopup.core.CenterPopupView;
import com.seuic.hnjiningposapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class RemittancePopup extends CenterPopupView {//交易成功弹窗
    Context context;
    Activity activity;
    Unbinder bind;
    ClickCallback callevent;
    @BindView(R.id.input_money_title)
    TextView inputMoneyTitle;
    @BindView(R.id.input_money_edtext)
    EditText inputMoneyEdtext;
    @BindView(R.id.input_money_gzbtn)
    Button inputMoneyGzbtn;
    @BindView(R.id.input_money_okbtn)
    Button inputMoneyOkbtn;
    @BindView(R.id.input_money_layout)
    LinearLayout inputMoneyLayout;
    @BindView(R.id.sure_remittance_title)
    TextView sureRemittanceTitle;
    @BindView(R.id.sure_remittance_num)
    TextView sureRemittanceNum;
    @BindView(R.id.sure_remittance_money)
    TextView sureRemittanceMoney;
    @BindView(R.id.sure_remittance_namea)
    TextView sureRemittanceNamea;
    @BindView(R.id.sure_remittance_gzbtn)
    Button sureRemittanceGzbtn;
    @BindView(R.id.sure_remittance_okbtn)
    Button sureRemittanceOkbtn;
    @BindView(R.id.sure_remittance_layout)
    LinearLayout sureRemittanceLayout;

    public RemittancePopup(@NonNull Context context, Activity activity, ClickCallback callevent) {
        super(context);
        this.context = context;
        this.activity = activity;
        this.callevent = callevent;
    }
    @OnClick({R.id.input_money_gzbtn, R.id.input_money_okbtn, R.id.sure_remittance_gzbtn, R.id.sure_remittance_okbtn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.input_money_gzbtn:
                inputMoneyEdtext.setText("");
                break;
            case R.id.input_money_okbtn:
                if (inputMoneyEdtext.getText().toString().equals("")) {
                    ToastUtils.showLong("请输入金额");
                }else {
                    sureRemittanceMoney.setText(inputMoneyEdtext.getText().toString());
                    inputMoneyLayout.setVisibility(View.GONE);
                    sureRemittanceLayout.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.sure_remittance_gzbtn:
                inputMoneyLayout.setVisibility(View.VISIBLE);
                sureRemittanceLayout.setVisibility(View.GONE);
                break;
            case R.id.sure_remittance_okbtn:
                callevent.OKRemittance(inputMoneyEdtext.getText().toString());
                break;
        }
    }

    public interface ClickCallback {
        void OKRemittance(String money);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_remittance;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);
        sureRemittanceNamea.setText(data_name);
        sureRemittanceNum.setText(data_bankid);
    }

    protected void onShow() {
        super.onShow();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }

    String data_name;
    String data_bankid;

    public void setContent(String bankid,String name) {
        data_name = name; //只记录数据，不再操作View
        data_bankid = bankid; //只记录数据，不再操作View
    }
}